import { parseHeaderToMarkdown } from '@/components/tMd/BlockTypeParsers/HeaderTypeParser';
import { parseParagraphToMarkdown } from '@/components/tMd/BlockTypeParsers/ParagraphTypeParser';
import { parseListToMarkdown } from '@/components/tMd/BlockTypeParsers/ListTypeParser';
import { parseDelimiterToMarkdown } from '@/components/tMd/BlockTypeParsers/DelimiterTypeParser';
import { parseImageToMarkdown } from '@/components/tMd/BlockTypeParsers/ImageTypeParser';
import { parseCheckboxToMarkdown } from '@/components/tMd/BlockTypeParsers/CheckboxTypeParser';
import { parseQuoteToMarkdown } from '@/components/tMd/BlockTypeParsers/QuoteTypeParser';
import { parseCodeToMarkdown } from '@/components/tMd/BlockTypeParsers/CodeTypeParser';
import { parseLinkToMarkdown } from '@/components/tMd/BlockTypeParsers/LinkTypeParser';
import { parseAudioToMarkdown, parseVideoToMarkdown, parseTableToMarkdown } from '@/components/tMd/BlockTypeParsers/MediaTypeParser';

// 输出md格式文档
export const outputMdTest = (data:any) =>{
    const initialData:any = {};
    initialData.content = data.blocks;
    const parsedData = initialData.content.map((item:any) => {
        // iterate through editor data and parse the single blocks to markdown syntax
        switch (item.type) {
          case 'header':
            return parseHeaderToMarkdown(item.data);
          case 'paragraph':
            return parseParagraphToMarkdown(item.data);
          case 'list':
            return parseListToMarkdown(item.data);
          case 'divider':
            return parseDelimiterToMarkdown(item);
          case 'audio':
            return parseAudioToMarkdown(item.data);
          case 'video':
            return parseVideoToMarkdown(item.data);
          case 'image':
            return parseImageToMarkdown(item.data);
          case 'link':
            return parseLinkToMarkdown(item.data);
          case 'table':
            return parseTableToMarkdown(item.data);
          case 'quote':
          case 'alert':
            return parseQuoteToMarkdown(item.data);
          case 'checkbox':
            return parseCheckboxToMarkdown(item.data);
          case 'codeBox':
            return parseCodeToMarkdown(item.data);
          case 'checklist':
            return parseCheckboxToMarkdown(item.data);
          default:
            break;
        }
      });
      return parsedData.join('\n')
} 